package com.example.teachdemo4;

import androidx.appcompat.app.AppCompatActivity;

import android.content.SharedPreferences;
import android.os.Bundle;
import android.widget.TextView;

public class TestPreferenceActivity extends AppCompatActivity {
    TextView tv_user;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_test_preference);

        tv_user = findViewById(R.id.tv_user);

        SharedPreferences preferences = getSharedPreferences("mydata",MODE_PRIVATE);

        tv_user.setText(preferences.getString("key_user","你拿不到"));
    }
}
